{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="{% static 'entering/img/333.jpg' %}">
	<title>Document</title>
	<link href="{% static 'entering/css/bootstrap.min.css' %}" rel="stylesheet">
    <script type="text/javascript" src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> 
	<style type="text/css">
        body{
          background: url("{% static 'entering/img/111.jpg' %}")  no-repeat center;
          background-size: cover;
          width: 100%;
        }
        .fa{
        	margin-top: 300px;
        }
    </style>
</head>
<body>
	<div class="container">
		<div class="row">
        	<div class="col-md-4">
        	</div>
        	<div class="col-md-4">
				<form class="form-signin" action="{% url 'entering:entering_yunsuan' %}" method="post" enctype="multipart/form-data">
					{% csrf_token %}
                    
                <span class="btn btn-success fileinput-button fa">
                    <!-- {% if message %}
                        {{message}}
                    {% endif %}
                    {% if message_k %}
                        {{message_k}}
                    {% endif %}
                    {% if message_z %}
                        {{message_z}}
                    {% endif %} -->
                    <h4 style="color: red;">点击浏览上传文件</h4>
                    <label for="excelFile" class="sr-only">文件</label>
                    <input type="file" name="excel" id="excelFile" required autofocus onchange="myfun()">
                    <input type="text" name="paper_name" class="form-control" required autofocus placeholder="试卷名字">
                    <button id="tj" class="btn btn-info btn-block" type="button" onclick="myts1()">上传</button>
                </span>
                    
                    
				</form>
			</div>
			<div class="col-md-4">
        	</div>
		</div>
	</div>
    
    {% if message %}
    <script type="text/javascript">
        function myts(){
            swal("提示","保存成功！","success")
        }
        myts()
    </script>
    {% endif %}
    {% if message_k %}
    <script type="text/javascript">
        function myts_k(){
            swal("提示","您上传的Excel内容为空请重新上传！","error")
        }
        myts_k()
    </script>
    {% endif %}
    {% if message_z %}
    <script type="text/javascript">
        function myts_z(){
            swal("提示","试卷名字已存在请重新输入！","error")
        }
        myts_z()
    </script>
    {% endif %}
    <script type="text/javascript">
             
        function myfun(){
            var fileName=document.getElementById("excelFile").value;  
            var suffixIndex=fileName.lastIndexOf(".");  
            var suffix=fileName.substring(suffixIndex+1).toUpperCase();  
            if(suffix!="XLS" && suffix!="XLSX"){  
                swal( "提示","请上传Excel表（格式xls、xlsx等）!","error");  
                }else{
                    document.getElementById("tj").type="submit"; 
                }
        };
        function myts1(){
            
            s=document.getElementById("tj")
            a=document.getElementById("excelFile")
            if (s.type != "button" && a.value != {{message_z}}) {
                swal("提示","正在保存请稍后······")
            }else{
                swal("提示","请确认已选择上传文件和已输入试卷名字");
            }
        };
    </script>
    
<script type="text/javascript" src="{% static 'entering/js/jquery-3.3.1.min.js' %}"></script>
<!-- Bootstrap部分： -->
<script type="text/javascript" src="{% static 'entering/js/bootstrap.min.js' %}"></script>
</body>
</html>